package es

import (
	"github.com/elastic/go-elasticsearch/v7"
	"log"
)

var EsClient *elasticsearch.Client
var err error

func Init() {
	cfg := elasticsearch.Config{
		Addresses: []string{
			"http://localhost:9200",
			"http://localhost:9201",
		},
		// ...
	}
	EsClient, err = elasticsearch.NewClient(cfg)
	_, err = EsClient.Info()
	if err != nil {
		panic(err)
	}

	log.Println("es数据库连接成功")
}
